macro(detect_msvc_ver)
    # Detect compiler.
    if(MSVC_VERSION MATCHES 1800)
        # Visual Studio 2013
        set(COMPILER 120)
    elseif(MSVC_VERSION MATCHES 1900)
        # Visual Studio 2015
        set(COMPILER 140)
    elseif(MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS 1920)
        # Visual Studio 2017
        set(COMPILER 141)
    elseif(MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1930)
        # Visual Studio 2019
        set(COMPILER 142)
    elseif(MSVC)
        message("Warning:[Cubism SDK] Unsupported Visual C++ compiler used.")
        message("But it seems msvc v143 can link the lib compiled by msvc v142.")
        message("Set /GL- to disable whole program optimization.")
        message("Project will try to use Cubism SDK compiled by msvc v142!")
        # Visual Studio 2019
        set(COMPILER 142)

    else()
        message("Warning:[Cubism SDK]  Unsupported compiler used.")
        message("Project will try to use Cubism SDK compiled by msvc v142!")
        set(COMPILER 142)

    endif()
endmacro()